function leapYears() {
    // 计算闰年
    var year = parseInt(document.getElementById("year").value);
    var output = document.getElementById("output");
    output.innerHTML = year + " 年后的10 个闰年: ";
    var count = 0;
    while (count < 10) {
        if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
            count++;
            output.innerHTML += " " + year;
        }
        year++;
    }
}

function donation() {
    // 使用||运算符提供一个缺少值
    var textField = document.getElementById("donationamount");
    var donation = textField.value || 5.00;
    alert("您已捐款" + donation + "元");
}

function cap() {
    // 单数位大写，双数位小写
    var input = document.getElementById("name");
    var name = input.value;
    var newName = "";
    for (var index = 0; index < name.length; index++) {
        if (index % 2 == 0) {
            newName += name.charAt(index).toUpperCase();
        } else {
            newName += name.charAt(index).toLowerCase();
        }
    }
    input.value = newName;   
}